class {{classname}} extends BaseModel
{
    {{~#if vendorExtensions.x-expose-headers}}
    use HasResponseHeaders;{{/if}}
    
    public const DISCRIMINATOR = {{#if discriminator}}'{{discriminatorName}}'{{else}}null{{/if}};

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static string $openAPIModelName = '{{name}}';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static array $openAPITypes = [
        {{#each vars}}'{{name}}' => '{{{dataType}}}'{{#unless @last}},
        {{/unless}}{{/each}}
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string|null>
      * @psalm-var array<string, string|null>
      */
    protected static array $openAPIFormats = [
        {{#each vars}}'{{name}}' => {{#if dataFormat}}'{{{dataFormat}}}'{{else}}null{{/if}}{{#unless @last}},
        {{/unless}}{{/each}}
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        {{#each vars}}'{{name}}' => {{#if isNullable}}true{{else}}false{{/if}}{{#unless @last}},
		{{/unless}}{{/each}}
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static array $attributeMap = [
        {{#each vars}}'{{name}}' => '{{baseName}}'{{#unless @last}},
        {{/unless}}{{/each}}
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static array $setters = [
        {{#each vars}}'{{name}}' => '{{setter}}'{{#unless @last}},
        {{/unless}}{{/each}}
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static array $getters = [
        {{#each vars}}'{{name}}' => '{{getter}}'{{#unless @last}},
        {{/unless}}{{/each}}
    ];

    {{#vars~}}
    {{#if isEnum~}}
    {{#allowableValues~}}
    {{#enumVars}}
    public const {{enumName}}_{{{name}}} = {{{value}}};
    {{/enumVars~}}
    {{/allowableValues~}}
    {{/if~}}
    {{/vars~}}

    {{#vars~}}
    {{#if isEnum}}
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function {{getter}}AllowableValues()
    {
        return [
            {{#allowableValues}}{{#each enumVars}}self::{{enumName}}_{{{name}}},{{#unless @last}}
            {{/unless}}{{/each}}{{/allowableValues}}
        ];
    }

    {{/if~}}
    {{/vars~}}
    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    { {{~#vars}}
        $this->setIfExists('{{name}}', $data ?? [], {{#if defaultValue}}{{{defaultValue}}}{{else}}null{{/if}});{{/vars}}
        {{~#if discriminator}}

        // Initialize discriminator property with the model name.
        $this->container['{{discriminatorName}}'] = static::$openAPIModelName;{{/if}}
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        {{#vars~}}
        {{#if required~}}
        if ($this->container['{{name}}'] === null) {
            $invalidProperties[] = "'{{name}}' can't be null";
        }
        {{/if~}}
        {{#if isEnum~}}
        {{#unless isContainer~}}
        $allowedValues = $this->{{getter}}AllowableValues();
        if (!is_null($this->container['{{name}}']) && !in_array($this->container['{{name}}'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for '{{name}}', must be one of '%s'",
                $this->container['{{name}}'],
                implode("', '", $allowedValues)
            );
        }

        {{/unless~}}
        {{/if~}}
        {{#if hasValidation~}}
        {{#if maxLength~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}(mb_strlen($this->container['{{name}}']) > {{maxLength}})) {
            $invalidProperties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
        }

        {{/if}}
        {{#if minLength~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}(mb_strlen($this->container['{{name}}']) < {{minLength}})) {
            $invalidProperties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
        }

        {{/if}}
        {{#if maximum~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}($this->container['{{name}}'] >{{#if exclusiveMaximum}}={{/if}} {{maximum}})) {
            $invalidProperties[] = "invalid value for '{{name}}', must be smaller than {{#unless exclusiveMaximum}}or equal to {{/unless}}{{maximum}}.";
        }

        {{/if}}
        {{#if minimum~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}($this->container['{{name}}'] <{{#if exclusiveMinimum}}={{/if}} {{minimum}})) {
            $invalidProperties[] = "invalid value for '{{name}}', must be bigger than {{#unless exclusiveMinimum}}or equal to {{/unless}}{{minimum}}.";
        }

        {{/if}}
        {{#if pattern~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}!preg_match("{{{pattern}}}", $this->container['{{name}}'])) {
            $invalidProperties[] = "invalid value for '{{name}}', must be conform to the pattern {{{pattern}}}.";
        }

        {{/if}}
        {{#if maxItems~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}(count($this->container['{{name}}']) > {{maxItems}})) {
            $invalidProperties[] = "invalid value for '{{name}}', number of items must be less than or equal to {{{maxItems}}}.";
        }

        {{/if}}
        {{#if minItems~}}
        if ({{#unless required}}!is_null($this->container['{{name}}']) && {{/unless}}(count($this->container['{{name}}']) < {{minItems}})) {
            $invalidProperties[] = "invalid value for '{{name}}', number of items must be greater than or equal to {{{minItems}}}.";
        }

        {{~/if~}}
        {{/if~}}
        {{/vars}}
        return $invalidProperties;
    }
{{#vars}}
    /**
     * Gets {{name}}
     *
     * @return {{{dataType}}}{{#unless required}}|null{{/unless}}
    {{#if deprecated}}
     * @deprecated
    {{/if}}
     */
    public function {{getter}}()
    {
        return $this->container['{{name}}'];
    }

    /**
     * Sets {{name}}
     *
     * @param {{{dataType}}}{{#unless required}}|null{{/unless}} ${{name}}{{#if description}} {{{description}}}{{else}} {{{name}}}{{/if}}
     *
     * @return self
    {{#if deprecated}}
     * @deprecated
    {{/if}}
     */
    public function {{setter}}(${{name}})
    {
        {{#if isNullable~}}
        if (is_null(${{name}})) {
            array_push($this->openAPINullablesSetToNull, '{{name}}');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('{{name}}', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        {{~else~}}
        if (is_null(${{name}})) {
            throw new \InvalidArgumentException('non-nullable {{name}} cannot be null');
        }
        {{/if~}}
        {{#if isEnum~}}
        $allowedValues = $this->{{getter}}AllowableValues();
        {{#if isContainer~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}array_diff(${{{name}}}, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for '{{name}}', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        {{~else~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}!in_array(${{{name}}}, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for '{{name}}', must be one of '%s'",
                    ${{{name}}},
                    implode("', '", $allowedValues)
                )
            );
        }
        {{/if~}}
        {{/if~}}
        {{#if hasValidation~}}
        {{#if maxLength~}}
        if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(mb_strlen(${{name}}) > {{maxLength}})) {
            throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
        }{{/if}}
        {{#if minLength~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(mb_strlen(${{name}}) < {{minLength}})) {
            throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
        }
        {{/if}}
        {{#if maximum~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(${{name}} >{{#if exclusiveMaximum}}={{/if}} {{maximum}})) {
            throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than {{#unless exclusiveMaximum}}or equal to {{/unless}}{{maximum}}.');
        }
        {{/if}}
        {{#if minimum~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(${{name}} <{{#if exclusiveMinimum}}={{/if}} {{minimum}})) {
            throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than {{#unless exclusiveMinimum}}or equal to {{/unless}}{{minimum}}.');
        }
        {{/if}}
        {{#if pattern~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(!preg_match("{{{pattern}}}", ${{name}}))) {
            throw new \InvalidArgumentException("invalid value for \${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.");
        }
        {{/if}}
        {{#if maxItems~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(count(${{name}}) > {{maxItems}})) {
            throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.');
        }{{/if}}
        {{#if minItems~}}
        if ({{#if isNullable}}!is_null(${{name}}) && {{/if}}(count(${{name}}) < {{minItems}})) {
            throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.');
        }
        {{/if~}}
        {{/if}}
        $this->container['{{name}}'] = ${{name}};
        return $this;
    }{{#unless @last}}
{{/unless}}{{/vars}}
}